/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package AssignmentOne;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 *
 * @author Naomi
 */
public class StartupGUI {
    private final int FRAME_WIDTH = 800;
    private final int FRAME_HEIGHT = 600;
    private final int BUTTON_WIDTH = 400;
    private final int BUTTON_HEIGHT = 100;

    private JFrame window;
    private JPanel titlePanel;
    private JPanel buttonPanel;
    private JPanel instructionsPanel;
    private JLabel title;
    private JLabel purchaseInstructions;
    private JTextArea loginInstructions;
    private Font titleFont;
    private JButton purchaseTickets;
    private JButton login;
    private Dimension buttonSize;
    private static StartupGUI startup;


    public void createFrame(){
        window = new JFrame("Welcome to JCU Airlines");         //Create window and set title
        
        //Create the welcome title
        titlePanel = new JPanel();                              //Create a panel to show the welcome header text
        title = new JLabel("Welcome to JCU Airlines");          //Create the title
        titleFont = new Font("serif", Font.BOLD, 28);           //Set the titleFont properties
        title.setFont(titleFont);                               //Set the font properties to the title
        title.setAlignmentY(Component.CENTER_ALIGNMENT);        //Vertically center the title in the panel
        titlePanel.add(title);                                  //Add the title to the panel
        titlePanel.setPreferredSize(new Dimension(FRAME_WIDTH, (FRAME_HEIGHT / 4)));    //Set the size of the panel

        //Create the buttons        
        buttonPanel = new JPanel();                             //Create a panel to hold the buttons
        GridLayout buttonLayout = new GridLayout(3,3);          //Create a new grid layout
        buttonPanel.setLayout(buttonLayout);                    //Set the button panel to grid layout
        buttonLayout.setHgap(20);                               //Set the horizontal spacing between elements
        buttonLayout.setVgap(30);                               //Set the vertical spacing between elements

        purchaseTickets = new JButton("Purchase Tickets");          //Create the "Purchase Tickets" button
        purchaseTickets.setAlignmentX(Component.CENTER_ALIGNMENT);  //Centre the button
        //purchaseTickets.addActionListener(new PurchaseTickets()); //Set the action for the "Purchase Tickets" button
        purchaseInstructions = new JLabel("Click here to purchase flight tickets");     //Display the instructions to purchase a ticket
        
        login = new JButton("Login");                               //Create the "Login" button
        login.setAlignmentX(Component.CENTER_ALIGNMENT);            //Centre the button
        //login.addActionListener(new Login());                     //Set the action for the "Login" button
        loginInstructions = new JTextArea("Click here to login to the system and manage your account");    //Display the instructions to login to the system
        loginInstructions.setLineWrap(true);                        //Set line wrapping
        loginInstructions.setWrapStyleWord(true);                   //Set word wrapping
        loginInstructions.setEditable(false);                       //Make it uneditable
        loginInstructions.setBackground(null);                      //Make it transparent
        loginInstructions.setFont(new Font("sans serif", Font.BOLD, 12));   //Make the font bold
        loginInstructions.setAlignmentY(Component.CENTER_ALIGNMENT);

        buttonPanel.add(new JLabel(""));                        //For empty cell
        buttonPanel.add(purchaseTickets);                       //Add the button to the panel
        buttonPanel.add(purchaseInstructions);                  //Add the ticket purchasing instructions to the panel
        buttonPanel.add(new JLabel(""));                        //For empty cell
        buttonPanel.add(login);                                 //Add the button to the panel
        buttonPanel.add(loginInstructions);                     //Add the login instructions to the panel
        buttonPanel.add(new JLabel(""));                        //For empty cell
        buttonPanel.add(new JLabel(""));                        //For empty cell
        buttonPanel.add(new JLabel(""));                        //For empty cell

        //Add components to the window
        window.add(titlePanel, BorderLayout.NORTH);             //Add the panel to the top of the window
        window.add(buttonPanel, BorderLayout.CENTER);           //Add the panel to the middle of the window
       
        //Set the window properties
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  //Set default close option
        window.setSize(FRAME_WIDTH, FRAME_HEIGHT);                //Set the size of the window
        window.setVisible(true);                                //Set the components to visible
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        startup = new StartupGUI();       //Create a new instance of the StartupGUI
        startup.createFrame();
    }

    //class PurchaseTickets implements ActionListener {
        //Direct to page to purchase tickets
    //}

    //class Login implements ActionListener {
        //Direct to page to login
    //}

}
